package arithmetic.someAlgorithm;

/**
 * 懒汉式单例模式
 * @author lidd
 *
 */
public class Singleton2 {

	private static Singleton2 singleton2;
	private Singleton2() {}
	public static synchronized Singleton2 getInstance() {
		if(singleton2==null) {
			singleton2=new Singleton2();
		}
		return singleton2;
	}

	public void print() {
		System.out.println("呵呵呵");
	}

	public static void main(String[] args) {
		Singleton1 s = Singleton1.getInstance();
		s.print();
	}
}
